home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / emacs.lha / emacs-19.16 / info / emacs-8 (.txt) < prev    next >
GNU Info File  |  1993-07-06  |  48KB  |  869 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.54 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: Menu Bars,  Next: Faces,  Prev: Scroll Bars,  Up: Frames
  4. Menu Bars
  5. =========
  6.    By default, each Emacs frame has a menu bar at the top which you can
  7. use to perform certain common operations.  There's no need to describe
  8. them in detail here, as you can more easily see for yourself; also, we
  9. may change them and add to them in subsequent Emacs versions.
  10.    Each of the operations in the menu bar is bound to an ordinary Emacs
  11. command which you can invoke equally well with `M-x' or with its own
  12. key bindings.  To see the command's name and documentation, type `C-h
  13. k' and then select the menu bar item you are interested in.
  14.    You can turn display of menu bars on or off with `M-x menu-bar-mode'.
  15. With no argument, this command toggles Menu Bar mode, a minor mode.
  16. With an argument, the command turns Menu Bar mode on if the argument is
  17. positive, off if the argument is not positive.
  18. File: emacs,  Node: Faces,  Next: Misc X,  Prev: Menu Bars,  Up: Frames
  19. Using Multiple Typefaces
  20. ========================
  21.    When using Emacs with X, you can set up multiple styles of displaying
  22. characters.  The aspects of style that you can control are the type
  23. font, the foreground color, the background color, and whether to
  24. underline.
  25.    The way you control display style is by defining named "faces".
  26. Each face can specify a type font, a foreground color, a background
  27. color, and an underline flag; but it does not have to specify all of
  28. them.
  29.    The style of display used for a given character in the text is
  30. determined by combining several faces.  Which faces to use is always set
  31. up by Lisp programs, at present, by means of text properties and
  32. overlays.  Any aspect of the display style that isn't specified by
  33. overlays or text properties comes from the frame itself.
  34.    When Transient Mark mode is enabled, the text of the region is
  35. highlighted when the mark is active.  This uses a face named `region';
  36. you can control the style of highlighting by changing the style of this
  37. face with the commands below.  *Note Setting Mark::, for more
  38. information about Transient Mark mode and activation and deactivation
  39. of the mark.
  40.    Here are the commands for users to change the font of a face.
  41. `M-x set-face-font RET FACE RET FONT RET'
  42.      Use font FONT in face FACE.
  43. `M-x make-face-bold RET FACE RET'
  44.      Convert face FACE to use a bold version of its current font.
  45. `M-x make-face-italic RET FACE RET'
  46.      Convert face FACE to use a italic version of its current font.
  47. `M-x make-face-bold-italic RET FACE RET'
  48.      Convert face FACE to use a bold-italic version of its current font.
  49. `M-x make-face-unbold RET FACE RET'
  50.      Convert face FACE to use a non-bold version of its current font.
  51. `M-x make-face-unitalic RET FACE RET'
  52.      Convert face FACE to use a non-italic version of its current font.
  53.    Here are the commands for users to set the colors and underline flag
  54. of a face:
  55. `M-x set-face-foreground RET FACE RET COLOR RET'
  56.      Use color COLOR for the foreground of characters in face FACE.
  57. `M-x set-face-background RET FACE RET COLOR RET'
  58.      Use color COLOR for the background of characters in face FACE.
  59. `M-x set-face-underline-p RET FACE RET FLAG RET'
  60.      Specify whether to underline characters in face FACE.
  61. `M-x invert-face RET FACE RET'
  62.      Swap the foreground and background colors of face FACE.
  63. File: emacs,  Node: Misc X,  Prev: Faces,  Up: Frames
  64. Miscellaneous X Window Features
  65. ===============================
  66.    To iconify the selected Emacs frame, type `C-z'.  The normal meaning
  67. of `C-z', to suspend Emacs, is not useful under a window system, so it
  68. has a different binding in that case (the command `iconify-frame').
  69.    To delete the selected frame, type `C-x 5 0'.
  70.    Under X Windows, when Transient Mark mode is enabled, Emacs
  71. highlights the region when the mark is active.  This is the main motive
  72. for using Transient Mark mode.  To enable this mode, use the command
  73. `M-x transient-mark-mode'.  *Note Mark::.
  74. File: emacs,  Node: Major Modes,  Next: Indentation,  Prev: Frames,  Up: Top
  75. Major Modes
  76. ***********
  77.    Emacs provides many alternative "major modes", each of which
  78. customizes Emacs for editing text of a particular sort.  The major modes
  79. are mutually exclusive, and each buffer has one major mode at any time.
  80. The mode line normally shows the name of the current major mode, in
  81. parentheses (*note Mode Line::.).
  82.    The least specialized major mode is called "Fundamental mode".  This
  83. mode has no mode-specific redefinitions or variable settings, so that
  84. each Emacs command behaves in its most general manner, and each option
  85. is in its default state.  For editing any specific type of text, such
  86. as Lisp code or English text, you should switch to the appropriate
  87. major mode, such as Lisp mode or Text mode.
  88.    Selecting a major mode changes the meanings of a few keys to become
  89. more specifically adapted to the language being edited.  The ones which
  90. are changed frequently are TAB, DEL, and LFD.  In addition, the
  91. commands which handle comments use the mode to determine how comments
  92. are to be delimited.  Many major modes redefine the syntactical
  93. properties of characters appearing in the buffer.  *Note Syntax::.
  94.    The major modes fall into three major groups.  Lisp mode (which has
  95. several variants), C mode, Fortran mode and others are for specific
  96. programming languages.  Text mode, Nroff mode, TeX mode and Outline
  97. mode are for editing English text.  The remaining major modes are not
  98. intended for use on users' files; they are used in buffers created for
  99. specific purposes by Emacs, such as Dired mode for buffers made by Dired
  100. (*note Dired::.), and Mail mode for buffers made by `C-x m' (*note
  101. Sending Mail::.), and Shell mode for buffers used for communicating
  102. with an inferior shell process (*note Interactive Shell::.).
  103.    Most programming language major modes specify that only blank lines
  104. separate paragraphs.  This is so that the paragraph commands remain
  105. useful.  (*Note Paragraphs::.)  They also cause Auto Fill mode to use
  106. the definition of TAB to indent the new lines it creates.  This is
  107. because most lines in a program are usually indented.  (*Note
  108. Indentation::.)
  109. * Menu:
  110. * Choosing Modes::     How major modes are specified or chosen.
  111. File: emacs,  Node: Choosing Modes,  Prev: Major Modes,  Up: Major Modes
  112. How Major Modes are Chosen
  113. ==========================
  114.    You can select a major mode explicitly for the current buffer, but
  115. most of the time Emacs determines which mode to use based on the file
  116. name or on special text in the file.
  117.    Explicit selection of a new major mode is done with a `M-x' command.
  118. From the name of a major mode, add `-mode' to get the name of a command
  119. to select that mode.  Thus, you can enter Lisp mode by executing `M-x
  120. lisp-mode'.
  121.    When you visit a file, Emacs usually chooses the right major mode
  122. based on the file's name.  For example, files whose names end in `.c'
  123. are edited in C mode.  The correspondence between file names and major
  124. mode is controlled by the variable `auto-mode-alist'.  Its value is a
  125. list in which each element has the form
  126.      (REGEXP . MODE-FUNCTION)
  127. For example, one element normally found in the list has the form
  128. `("\\.c$" . c-mode)', and it is responsible for selecting C mode for
  129. files whose names end in `.c'.  (Note that `\\' is needed in Lisp
  130. syntax to include a `\' in the string, which is needed to suppress the
  131. special meaning of `.' in regexps.)  The only practical way to change
  132. this variable is with Lisp code.
  133.    You can specify which major mode should be used for editing a certain
  134. file by a special sort of text in the first nonblank line of the file.
  135. The mode name should appear in this line both preceded and followed by
  136. `-*-'.  Other text may appear on the line as well.  For example,
  137.      ;-*-Lisp-*-
  138. tells Emacs to use Lisp mode.  Such an explicit specification overrides
  139. any defaulting based on the file name.  Note how the semicolon is used
  140. to make Lisp treat this line as a comment.
  141.    Another format of mode specification is
  142.      -*-Mode: MODENAME;-*-
  143. which allows you to specify local variables as well, like this:
  144.      -*- mode: MODENAME; VAR: VALUE; ... -*-
  145. *Note File Variables::, for more information about this.
  146.    When you visit a file that does not specify a major mode to use, or
  147. when you create a new buffer with `C-x b', the variable
  148. `default-major-mode' specifies which major mode to use.  Normally its
  149. value is the symbol `fundamental-mode', which specifies Fundamental
  150. mode.  If `default-major-mode' is `nil', the major mode is taken from
  151. the previously selected buffer.
  152.    If you change the major mode of a buffer, you can go back to the
  153. major mode Emacs would choose automatically: use the command `M-x
  154. normal-mode' to do this.  This is the same function that `find-file'
  155. calls to choose the major mode.  It also processes the file's local
  156. variables list if any.
  157. File: emacs,  Node: Indentation,  Next: Text,  Prev: Major Modes,  Up: Top
  158. Indentation
  159. ***********
  160.    This chapter describes the Emacs commands that add, remove, or
  161. adjust indentation.
  162. `TAB'
  163.      Indent current line "appropriately" in a mode-dependent fashion.
  164. `LFD'
  165.      Perform RET followed by TAB (`newline-and-indent').
  166. `M-^'
  167.      Merge two lines (`delete-indentation').  This would cancel out the
  168.      effect of LFD.
  169. `C-M-o'
  170.      Split line at point; text on the line after point becomes a new
  171.      line indented to the same column that it now starts in
  172.      (`split-line').
  173. `M-m'
  174.      Move (forward or back) to the first nonblank character on the
  175.      current line (`back-to-indentation').
  176. `C-M-\'
  177.      Indent several lines to same column (`indent-region').
  178. `C-x TAB'
  179.      Shift block of lines rigidly right or left (`indent-rigidly').
  180. `M-i'
  181.      Indent from point to the next prespecified tab stop column
  182.      (`tab-to-tab-stop').
  183. `M-x indent-relative'
  184.      Indent from point to under an indentation point in the previous
  185.      line.
  186.    Most programming languages have some indentation convention.  For
  187. Lisp code, lines are indented according to their nesting in
  188. parentheses.  The same general idea is used for C code, though many
  189. details are different.
  190.    Whatever the language, to indent a line, use the TAB command.  Each
  191. major mode defines this command to perform the sort of indentation
  192. appropriate for the particular language.  In Lisp mode, TAB aligns the
  193. line according to its depth in parentheses.  No matter where in the
  194. line you are when you type TAB, it aligns the line as a whole.  In C
  195. mode, TAB implements a subtle and sophisticated indentation style that
  196. knows about many aspects of C syntax.
  197.    In Text mode, TAB runs the command `tab-to-tab-stop', which indents
  198. to the next tab stop column.  You can set the tab stops with `M-x
  199. edit-tab-stops'.
  200. * Menu:
  201. * Indentation Commands::  Various commands and techniques for indentation.
  202. * Tab Stops::             You can set arbitrary "tab stops" and then
  203.                             indent to the next tab stop when you want to.
  204. * Just Spaces::           You can request indentation using just spaces.
  205. File: emacs,  Node: Indentation Commands,  Next: Tab Stops,  Prev: Indentation,  Up: Indentation
  206. Indentation Commands and Techniques
  207. ===================================
  208.    If you just want to insert a tab character in the buffer, you can
  209. type `C-q TAB'.
  210.    To move over the indentation on a line, do `M-m'
  211. (`back-to-indentation').  This command, given anywhere on a line,
  212. positions point at the first nonblank character on the line.
  213.    To insert an indented line before the current line, do `C-a C-o
  214. TAB'.  To make an indented line after the current line, use `C-e LFD'.
  215.    `C-M-o' (`split-line') moves the text from point to the end of the
  216. line vertically down, so that the current line becomes two lines.
  217. `C-M-o' first moves point forward over any spaces and tabs.  Then it
  218. inserts after point a newline and enough indentation to reach the same
  219. column point is on.  Point remains before the inserted newline; in this
  220. regard, `C-M-o' resembles `C-o'.
  221.    To join two lines cleanly, use the `M-^' (`delete-indentation')
  222. command.  It deletes the indentation at the front of the current line,
  223. and the line boundary as well, replacing them with a single space.  As
  224. a special case (useful for Lisp code) the single space is omitted if
  225. the characters to be joined are consecutive open parentheses or closing
  226. parentheses, or if the junction follows another newline.  To delete
  227. just the indentation of a line, go to the beginning of the line and use
  228. `M-\' (`delete-horizontal-space'), which deletes all spaces and tabs
  229. around the cursor.
  230.    If you have a fill prefix, `M-^' deletes the fill prefix if it
  231. appears after the newline that is deleted.  *Note Fill Prefix::.
  232.    There are also commands for changing the indentation of several
  233. lines at once.  `C-M-\' (`indent-region') gives each line which begins
  234. in the region the "usual" indentation by invoking TAB at the beginning
  235. of the line.  A numeric argument specifies the column to indent to, and
  236. each line is shifted left or right so that its first nonblank character
  237. appears in that column.  `C-x TAB' (`indent-rigidly') moves all of the
  238. lines in the region right by its argument (left, for negative
  239. arguments).  The whole group of lines moves rigidly sideways, which is
  240. how the command gets its name.
  241.    `M-x indent-relative' indents at point based on the previous line
  242. (actually, the last nonempty line).  It inserts whitespace at point,
  243. moving point, until it is underneath an indentation point in the
  244. previous line.  An indentation point is the end of a sequence of
  245. whitespace or the end of the line.  If point is farther right than any
  246. indentation point in the previous line, the whitespace before point is
  247. deleted and the first indentation point then applicable is used.  If no
  248. indentation point is applicable even then, `indent-relative' runs
  249. `tab-to-tab-stop' (*note Tab Stops::.).
  250.    `indent-relative' is the definition of TAB in Indented Text mode.
  251. *Note Text::.
  252. File: emacs,  Node: Tab Stops,  Next: Just Spaces,  Prev: Indentation Commands,  Up: Indentation
  253. Tab Stops
  254. =========
  255.    For typing in tables, you can use Text mode's definition of TAB,
  256. `tab-to-tab-stop'.  This command inserts indentation before point,
  257. enough to reach the next tab stop column.  If you are not in Text mode,
  258. this command can be found on the key `M-i'.
  259.    You can specify the tab stops used by `M-i'.  They are stored in a
  260. variable called `tab-stop-list', as a list of column-numbers in
  261. increasing order.
  262.    The convenient way to set the tab stops is with `M-x edit-tab-stops',
  263. which creates and selects a buffer containing a description of the tab
  264. stop settings.  You can edit this buffer to specify different tab
  265. stops, and then type `C-c C-c' to make those new tab stops take effect.
  266. In the tab stop buffer, `C-c C-c' runs the function
  267. `edit-tab-stops-note-changes' rather than its usual definition
  268. `save-buffer'.  `edit-tab-stops' records which buffer was current when
  269. you invoked it, and stores the tab stops back in that buffer; normally
  270. all buffers share the same tab stops and changing them in one buffer
  271. affects all, but if you happen to make `tab-stop-list' local in one
  272. buffer then `edit-tab-stops' in that buffer will edit the local
  273. settings.
  274.    Here is what the text representing the tab stops looks like for
  275. ordinary tab stops every eight columns.
  276.              :       :       :       :       :       :
  277.      0         1         2         3         4
  278.      0123456789012345678901234567890123456789012345678
  279.      To install changes, type C-c C-c
  280.    The first line contains a colon at each tab stop.  The remaining
  281. lines are present just to help you see where the colons are and know
  282. what to do.
  283.    Note that the tab stops that control `tab-to-tab-stop' have nothing
  284. to do with displaying tab characters in the buffer.  *Note Display
  285. Vars::, for more information on that.
  286. File: emacs,  Node: Just Spaces,  Prev: Tab Stops,  Up: Indentation
  287. Tabs vs. Spaces
  288. ===============
  289.    Emacs normally uses both tabs and spaces to indent lines.  If you
  290. prefer, all indentation can be made from spaces only.  To request this,
  291. set `indent-tabs-mode' to `nil'.  This is a per-buffer variable;
  292. altering the variable affects only the current buffer, but there is a
  293. default value which you can change as well.  *Note Locals::.
  294.    There are also commands to convert tabs to spaces or vice versa,
  295. always preserving the columns of all nonblank text.  `M-x tabify' scans
  296. the region for sequences of spaces, and converts sequences of at least
  297. three spaces to tabs if that can be done without changing indentation.
  298. `M-x untabify' changes all tabs in the region to appropriate numbers of
  299. spaces.
  300. File: emacs,  Node: Text,  Next: Programs,  Prev: Indentation,  Up: Top
  301. Commands for Human Languages
  302. ****************************
  303.    The term "text" has two widespread meanings in our area of the
  304. computer field.  One is data that is a sequence of characters.  Any file
  305. that you edit with Emacs is text, in this sense of the word.  The other
  306. meaning is more restrictive: a sequence of characters in a human
  307. language for humans to read (possibly after processing by a text
  308. formatter), as opposed to a program or commands for a program.
  309.    Human languages have syntactic/stylistic conventions that can be
  310. supported or used to advantage by editor commands: conventions involving
  311. words, sentences, paragraphs, and capital letters.  This chapter
  312. describes Emacs commands for all of these things.  There are also
  313. commands for "filling", which means rearranging the lines of a
  314. paragraph to be approximately equal in length.  The commands for moving
  315. over and killing words, sentences and paragraphs, while intended
  316. primarily for editing text, are also often useful for editing programs.
  317.    Emacs has several major modes for editing human language text.  If
  318. the file contains text pure and simple, use Text mode, which customizes
  319. Emacs in small ways for the syntactic conventions of text.  For text
  320. which contains embedded commands for text formatters, Emacs has other
  321. major modes, each for a particular text formatter.  Thus, for input to
  322. TeX, you would use TeX mode; for input to nroff, Nroff mode.
  323. * Menu:
  324. * Words::         Moving over and killing words.
  325. * Sentences::     Moving over and killing sentences.
  326. * Paragraphs::      Moving over paragraphs.
  327. * Pages::      Moving over pages.
  328. * Filling::       Filling or justifying text.
  329. * Case::          Changing the case of text.
  330. * Text Mode::     The major modes for editing text files.
  331. * Outline Mode::  The major mode for editing outlines.
  332. * TeX Mode::      The major modes for editing input to the formatter TeX.
  333. * Nroff Mode::    The major mode for editing input to the formatter nroff.
  334. File: emacs,  Node: Words,  Next: Sentences,  Up: Text
  335. Words
  336. =====
  337.    Emacs has commands for moving over or operating on words.  By
  338. convention, the keys for them are all Meta characters.
  339. `M-f'
  340.      Move forward over a word (`forward-word').
  341. `M-b'
  342.      Move backward over a word (`backward-word').
  343. `M-d'
  344.      Kill up to the end of a word (`kill-word').
  345. `M-DEL'
  346.      Kill back to the beginning of a word (`backward-kill-word').
  347. `M-@'
  348.      Mark the end of the next word (`mark-word').
  349. `M-t'
  350.      Transpose two words or drag a word across other words
  351.      (`transpose-words').
  352.    Notice how these keys form a series that parallels the
  353. character-based `C-f', `C-b', `C-d', `C-t' and DEL.  `M-@' is related
  354. to `C-@', which is an alias for `C-SPC'.
  355.    The commands `M-f' (`forward-word') and `M-b' (`backward-word') move
  356. forward and backward over words.  These Meta characters are thus
  357. analogous to the corresponding control characters, `C-f' and `C-b',
  358. which move over single characters in the text.  The analogy extends to
  359. numeric arguments, which serve as repeat counts.  `M-f' with a negative
  360. argument moves backward, and `M-b' with a negative argument moves
  361. forward.  Forward motion stops right after the last letter of the word,
  362. while backward motion stops right before the first letter.
  363.    `M-d' (`kill-word') kills the word after point.  To be precise, it
  364. kills everything from point to the place `M-f' would move to.  Thus, if
  365. point is in the middle of a word, `M-d' kills just the part after
  366. point.  If some punctuation comes between point and the next word, it
  367. is killed along with the word.  (If you wish to kill only the next word
  368. but not the punctuation before it, simply do `M-f' to get the end, and
  369. kill the word backwards with `M-DEL'.) `M-d' takes arguments just like
  370. `M-f'.
  371.    `M-DEL' (`backward-kill-word') kills the word before point.  It
  372. kills everything from point back to where `M-b' would move to.  If
  373. point is after the space in `FOO, BAR', then `FOO, ' is killed.  (If
  374. you wish to kill just `FOO', do `M-b M-d' instead of `M-DEL'.)
  375.    `M-t' (`transpose-words') exchanges the word before or containing
  376. point with the following word.  The delimiter characters between the
  377. words do not move.  For example, `FOO, BAR' transposes into `BAR, FOO'
  378. rather than `BAR FOO,'.  *Note Transpose::, for more on transposition
  379. and on arguments to transposition commands.
  380.    To operate on the next N words with an operation which applies
  381. between point and mark, you can either set the mark at point and then
  382. move over the words, or you can use the command `M-@' (`mark-word')
  383. which does not move point, but sets the mark where `M-f' would move to.
  384. `M-@' accepts a numeric argument that says how many words to scan for
  385. the place to put the mark.
  386.    The word commands' understanding of syntax is completely controlled
  387. by the syntax table.  Any character can, for example, be declared to be
  388. a word delimiter.  *Note Syntax::.
  389. File: emacs,  Node: Sentences,  Next: Paragraphs,  Prev: Words,  Up: Text
  390. Sentences
  391. =========
  392.    The Emacs commands for manipulating sentences and paragraphs are
  393. mostly on Meta keys, so as to be like the word-handling commands.
  394. `M-a'
  395.      Move back to the beginning of the sentence (`backward-sentence').
  396. `M-e'
  397.      Move forward to the end of the sentence (`forward-sentence').
  398. `M-k'
  399.      Kill forward to the end of the sentence (`kill-sentence').
  400. `C-x DEL'
  401.      Kill back to the beginning of the sentence
  402.      (`backward-kill-sentence').
  403.    The commands `M-a' and `M-e' (`backward-sentence' and
  404. `forward-sentence') move to the beginning and end of the current
  405. sentence, respectively.  They were chosen to resemble `C-a' and `C-e',
  406. which move to the beginning and end of a line.  Unlike them, `M-a' and
  407. `M-e' if repeated or given numeric arguments move over successive
  408. sentences.  Emacs assumes that the typist's convention is followed, and
  409. thus considers a sentence to end wherever there is a `.', `?' or `!'
  410. followed by the end of a line or two spaces, with any number of `)',
  411. `]', `'', or `"' characters allowed in between.  A sentence also begins
  412. or ends wherever a paragraph begins or ends.
  413.    Neither `M-a' nor `M-e' moves past the newline or spaces beyond the
  414. sentence edge at which it is stopping.
  415.    Just as `C-a' and `C-e' have a kill command, `C-k', to go with them,
  416. so `M-a' and `M-e' have a corresponding kill command `M-k'
  417. (`kill-sentence') which kills from point to the end of the sentence.
  418. With minus one as an argument it kills back to the beginning of the
  419. sentence.  Larger arguments serve as a repeat count.
  420.    There is a special command, `C-x DEL' (`backward-kill-sentence') for
  421. killing back to the beginning of a sentence, because this is useful
  422. when you change your mind in the middle of composing text.
  423.    The variable `sentence-end' controls recognition of the end of a
  424. sentence.  It is a regexp that matches the last few characters of a
  425. sentence, together with the whitespace following the sentence.  Its
  426. normal value is
  427.      "[.?!][]\"')]*\\($\\|\t\\|  \\)[ \t\n]*"
  428. This example is explained in the section on regexps.  *Note Regexps::.
  429. File: emacs,  Node: Paragraphs,  Next: Pages,  Prev: Sentences,  Up: Text
  430. Paragraphs
  431. ==========
  432.    The Emacs commands for manipulating paragraphs are also Meta keys.
  433. `M-{'
  434.      Move back to previous paragraph beginning (`backward-paragraph').
  435. `M-}'
  436.      Move forward to next paragraph end (`forward-paragraph').
  437. `M-h'
  438.      Put point and mark around this or next paragraph
  439.      (`mark-paragraph').
  440.    `M-{' moves to the beginning of the current or previous paragraph,
  441. while `M-}' moves to the end of the current or next paragraph.  Blank
  442. lines and text formatter command lines separate paragraphs and are not
  443. part of any paragraph.  Also, an indented line starts a new paragraph.
  444.    In major modes for programs (as opposed to Text mode), paragraphs
  445. begin and end only at blank lines.  This makes the paragraph commands
  446. continue to be useful even though there are no paragraphs per se.
  447.    When there is a fill prefix, then paragraphs are delimited by all
  448. lines which don't start with the fill prefix.  *Note Filling::.
  449.    When you wish to operate on a paragraph, you can use the command
  450. `M-h' (`mark-paragraph') to set the region around it.  This command
  451. puts point at the beginning and mark at the end of the paragraph point
  452. was in.  If point is between paragraphs (in a run of blank lines, or at
  453. a boundary), the paragraph following point is surrounded by point and
  454. mark.  If there are blank lines preceding the first line of the
  455. paragraph, one of these blank lines is included in the region.  Thus,
  456. for example, `M-h C-w' kills the paragraph around or after point.
  457.    The precise definition of a paragraph boundary is controlled by the
  458. variables `paragraph-separate' and `paragraph-start'.  The value of
  459. `paragraph-start' is a regexp that should match any line that either
  460. starts or separates paragraphs.  The value of `paragraph-separate' is
  461. another regexp that should match only lines that separate paragraphs
  462. without being part of any paragraph.  Lines that start a new paragraph
  463. and are contained in it must match both regexps.  For example, normally
  464. `paragraph-start' is `"^[ \t\n\f]"' and `paragraph-separate' is `"^[
  465. \t\f]*$"'.
  466.    Normally it is desirable for page boundaries to separate paragraphs.
  467. The default values of these variables recognize the usual separator for
  468. pages.
  469. File: emacs,  Node: Pages,  Next: Filling,  Prev: Paragraphs,  Up: Text
  470. Pages
  471. =====
  472.    Files are often thought of as divided into "pages" by the "formfeed"
  473. character (ASCII control-L, octal code 014).  For example, if a file is
  474. printed on a line printer, each page of the file, in this sense, will
  475. start on a new page of paper.  Emacs treats a page-separator character
  476. just like any other character.  You can insert it with `C-q C-l', or
  477. delete it with DEL.  Thus, you are free to paginate your file or not.
  478. However, since pages are often meaningful divisions of the file, Emacs
  479. provides commands to move over them and operate on them.
  480. `C-x ['
  481.      Move point to previous page boundary (`backward-page').
  482. `C-x ]'
  483.      Move point to next page boundary (`forward-page').
  484. `C-x C-p'
  485.      Put point and mark around this page (or another page)
  486.      (`mark-page').
  487. `C-x l'
  488.      Count the lines in this page (`count-lines-page').
  489.    The `C-x [' (`backward-page') command moves point to immediately
  490. after the previous page delimiter.  If point is already right after a
  491. page delimiter, it skips that one and stops at the previous one.  A
  492. numeric argument serves as a repeat count.  The `C-x ]' (`forward-page')
  493. command moves forward past the next page delimiter.
  494.    The `C-x C-p' command (`mark-page') puts point at the beginning of
  495. the current page and the mark at the end.  The page delimiter at the end
  496. is included (the mark follows it).  The page delimiter at the front is
  497. excluded (point follows it).  This command can be followed by `C-w' to
  498. kill a page which is to be moved elsewhere.  If it is inserted after a
  499. page delimiter, at a place where `C-x ]' or `C-x [' would take you, then
  500. the page will be properly delimited before and after once again.
  501.    A numeric argument to `C-x C-p' is used to specify which page to go
  502. to, relative to the current one.  Zero means the current page.  One
  503. means the next page, and -1 means the previous one.
  504.    The `C-x l' command (`count-lines-page') is good for deciding where
  505. to break a page in two.  It prints in the echo area the total number of
  506. lines in the current page, and then divides it up into those preceding
  507. the current line and those following, as in
  508.      Page has 96 (72+25) lines
  509. Notice that the sum is off by one; this is correct if point is not at
  510. the beginning of a line.
  511.    The variable `page-delimiter' controls where pages begin.  Its value
  512. is a regexp that matches the beginning of a line that separates pages.
  513. The normal value of this variable is `"^\f"', which matches a formfeed
  514. character at the beginning of a line.
  515. File: emacs,  Node: Filling,  Next: Case,  Prev: Pages,  Up: Text
  516. Filling Text
  517. ============
  518.    With Auto Fill mode, text can be "filled" (broken up into lines that
  519. fit in a specified width) as you insert it.  If you alter existing text
  520. it may no longer be properly filled; then you can use the explicit fill
  521. commands to fill the paragraph again.
  522. * Menu:
  523. * Auto Fill::       Auto Fill mode breaks long lines automatically.
  524. * Fill Commands::  Commands to refill paragraphs and center lines.
  525. * Fill Prefix::    Filling when every line is indented or in a comment, etc.
  526. File: emacs,  Node: Auto Fill,  Next: Fill Commands,  Up: Filling
  527. Auto Fill Mode
  528. --------------
  529.    "Auto Fill" mode is a minor mode in which lines are broken
  530. automatically when they become too wide.  Breaking happens only when
  531. you type a SPC or RET.
  532. `M-x auto-fill-mode'
  533.      Enable or disable Auto Fill mode.
  534. `SPC'
  535. `RET'
  536.      In Auto Fill mode, break lines when appropriate.
  537.    `M-x auto-fill-mode' turns Auto Fill mode on if it was off, or off if
  538. it was on.  With a positive numeric argument it always turns Auto Fill
  539. mode on, and with a negative argument always turns it off.  You can see
  540. when Auto Fill mode is in effect by the presence of the word `Fill' in
  541. the mode line, inside the parentheses.  Auto Fill mode is a minor mode,
  542. turned on or off for each buffer individually.  *Note Minor Modes::.
  543.    In Auto Fill mode, lines are broken automatically at spaces when
  544. they get longer than the desired width.  Line breaking and
  545. rearrangement takes place only when you type SPC or RET.  If you wish
  546. to insert a space or newline without permitting line-breaking, type
  547. `C-q SPC' or `C-q LFD' (recall that a newline is really a linefeed).
  548. Also, `C-o' inserts a newline without line breaking.
  549.    Auto Fill mode works well with Lisp mode, because when it makes a new
  550. line in Lisp mode it indents that line with TAB.  If a line ending in a
  551. comment gets too long, the text of the comment is split into two
  552. comment lines.  Optionally new comment delimiters are inserted at the
  553. end of the first line and the beginning of the second so that each line
  554. is a separate comment; the variable `comment-multi-line' controls the
  555. choice (*note Comments::.).
  556.    Auto Fill mode does not refill entire paragraphs.  It can break
  557. lines but cannot merge lines.  So editing in the middle of a paragraph
  558. can result in a paragraph that is not correctly filled.  The easiest
  559. way to make the paragraph properly filled again is usually with the
  560. explicit fill commands.  *Note Fill Commands::.
  561.    Many users like Auto Fill mode and want to use it in all text files.
  562. The section on init files says how to arrange this permanently for
  563. yourself.  *Note Init File::.
  564. File: emacs,  Node: Fill Commands,  Next: Fill Prefix,  Prev: Auto Fill,  Up: Filling
  565. Explicit Fill Commands
  566. ----------------------
  567. `M-q'
  568.      Fill current paragraph (`fill-paragraph').
  569. `C-x f'
  570.      Set the fill column (`set-fill-column').
  571. `M-x fill-region'
  572.      Fill each paragraph in the region (`fill-region').
  573. `M-x fill-region-as-paragraph.'
  574.      Fill the region, considering it as one paragraph.
  575. `M-s'
  576.      Center a line.
  577.    To refill a paragraph, use the command `M-q' (`fill-paragraph').
  578. This operates on the paragraph that point is inside, or the one after
  579. point if point is between paragraphs.  Refilling works by removing all
  580. the line-breaks, then inserting new ones where necessary.
  581.    The command `M-s' (`center-line') centers the current line within
  582. the current fill column.  With an argument, it centers several lines
  583. individually and moves past them.
  584.    To refill many paragraphs, use `M-x fill-region', which divides the
  585. region into paragraphs and fills each of them.
  586.    `M-q' and `fill-region' use the same criteria as `M-h' for finding
  587. paragraph boundaries (*note Paragraphs::.).  For more control, you can
  588. use `M-x fill-region-as-paragraph', which refills everything between
  589. point and mark.  This command deletes any blank lines within the
  590. region, so separate blocks of text end up combined into one block.
  591.    A numeric argument to `M-q' causes it to "justify" the text as well
  592. as filling it.  This means that extra spaces are inserted to make the
  593. right margin line up exactly at the fill column.  To remove the extra
  594. spaces, use `M-q' with no argument.  (Likewise for `fill-region'.)
  595.    When ADAPTIVE-FILL-MODE is non-`nil' (which is normally the case),
  596. if you use `fill-region-as-paragraph' on an indented paragraph and you
  597. don't have a fill prefix, it uses the indentation of the second line of
  598. the paragraph as the fill prefix.  The effect of adaptive filling is
  599. not noticeable in Text mode, because an indented line counts as a
  600. paragraph starter and thus each line of an indented paragraph is
  601. considered a paragraph of its own.  But you do notice the effect in
  602. Indented Text mode and some other major modes.
  603.    The maximum line width for filling is in the variable `fill-column'.
  604. Altering the value of `fill-column' makes it local to the current
  605. buffer; until that time, the default value is in effect.  The default is
  606. initially 70.  *Note Locals::.
  607.    The easiest way to set `fill-column' is to use the command `C-x f'
  608. (`set-fill-column').  With no argument, it sets `fill-column' to the
  609. current horizontal position of point.  With a numeric argument, it uses
  610. that as the new fill column.
  611. File: emacs,  Node: Fill Prefix,  Prev: Fill Commands,  Up: Filling
  612. The Fill Prefix
  613. ---------------
  614.    To fill a paragraph in which each line starts with a special marker
  615. (which might be a few spaces, giving an indented paragraph), use the
  616. "fill prefix" feature.  The fill prefix is a string which Emacs expects
  617. every line to start with, and which is not included in filling.
  618. `C-x .'
  619.      Set the fill prefix (`set-fill-prefix').
  620. `M-q'
  621.      Fill a paragraph using current fill prefix (`fill-paragraph').
  622. `M-x fill-individual-paragraphs'
  623.      Fill the region, considering each change of indentation as
  624.      starting a new paragraph.
  625. `M-x fill-nonuniform-paragraphs'
  626.      Fill the region, considering only paragraph-separator lines as
  627.      starting a new paragraph.
  628.    To specify a fill prefix, move to a line that starts with the desired
  629. prefix, put point at the end of the prefix, and give the command
  630. `C-x .' (`set-fill-prefix').  That's a period after the `C-x'.  To turn
  631. off the fill prefix, specify an empty prefix: type `C-x .' with point
  632. at the beginning of a line.
  633.    When a fill prefix is in effect, the fill commands remove the fill
  634. prefix from each line before filling and insert it on each line after
  635. filling.  The fill prefix is also inserted on new lines made
  636. automatically by Auto Fill mode.  Lines that do not start with the fill
  637. prefix are considered to start paragraphs, both in `M-q' and the
  638. paragraph commands; this is just right if you are using paragraphs with
  639. hanging indentation (every line indented except the first one).  Lines
  640. which are blank or indented once the prefix is removed also separate or
  641. start paragraphs; this is what you want if you are writing
  642. multi-paragraph comments with a comment delimiter on each line.
  643.    For example, if `fill-column' is 40 and you set the fill prefix to
  644. `;; ', then `M-q' in the following text
  645.      ;; This is an
  646.      ;; example of a paragraph
  647.      ;; inside a Lisp-style comment.
  648. produces this:
  649.      ;; This is an example of a paragraph
  650.      ;; inside a Lisp-style comment.
  651.    The `C-o' command inserts the fill prefix on new lines it creates,
  652. when you use it at the beginning of a line (*note Blank Lines::.).
  653. Conversely, the command `M-^' deletes the prefix (if it occurs) after
  654. the newline that it deletes (*note Indentation::.).
  655.    You can use `M-x fill-individual-paragraphs' to set the fill prefix
  656. for each paragraph automatically.  This command divides the region into
  657. paragraphs, treating every change in the amount of indentation as the
  658. start of a new paragraph, and fills each of these paragraphs.  Thus,
  659. all the lines in one "paragraph" have the same amount of indentation.
  660. That indentation serves as the fill prefix for that paragraph.
  661.    `M-x fill-nonuniform-paragraphs' is a similar command that divides
  662. the region into paragraphs in a different way.  It considers only
  663. paragraph-separating lines (as defined by `paragraph-separate') as
  664. starting a new paragraph.  Since this means that the lines of one
  665. paragraph may have different amounts of indentation, the fill prefix
  666. used is the smallest amount of indentation of any of the lines of the
  667. paragraph.
  668.    The fill prefix is stored in the variable `fill-prefix'.  Its value
  669. is a string, or `nil' when there is no fill prefix.  This is a
  670. per-buffer variable; altering the variable affects only the current
  671. buffer, but there is a default value which you can change as well.
  672. *Note Locals::.
  673. File: emacs,  Node: Case,  Next: Text Mode,  Prev: Filling,  Up: Text
  674. Case Conversion Commands
  675. ========================
  676.    Emacs has commands for converting either a single word or any
  677. arbitrary range of text to upper case or to lower case.
  678. `M-l'
  679.      Convert following word to lower case (`downcase-word').
  680. `M-u'
  681.      Convert following word to upper case (`upcase-word').
  682. `M-c'
  683.      Capitalize the following word (`capitalize-word').
  684. `C-x C-l'
  685.      Convert region to lower case (`downcase-region').
  686. `C-x C-u'
  687.      Convert region to upper case (`upcase-region').
  688.    The word conversion commands are the most useful.  `M-l'
  689. (`downcase-word') converts the word after point to lower case, moving
  690. past it.  Thus, repeating `M-l' converts successive words.  `M-u'
  691. (`upcase-word') converts to all capitals instead, while `M-c'
  692. (`capitalize-word') puts the first letter of the word into upper case
  693. and the rest into lower case.  All these commands convert several words
  694. at once if given an argument.  They are especially convenient for
  695. converting a large amount of text from all upper case to mixed case,
  696. because you can move through the text using `M-l', `M-u' or `M-c' on
  697. each word as appropriate, occasionally using `M-f' instead to skip a
  698. word.
  699.    When given a negative argument, the word case conversion commands
  700. apply to the appropriate number of words before point, but do not move
  701. point.  This is convenient when you have just typed a word in the wrong
  702. case: you can give the case conversion command and continue typing.
  703.    If a word case conversion command is given in the middle of a word,
  704. it applies only to the part of the word which follows point.  This is
  705. just like what `M-d' (`kill-word') does.  With a negative argument,
  706. case conversion applies only to the part of the word before point.
  707.    The other case conversion commands are `C-x C-u' (`upcase-region')
  708. and `C-x C-l' (`downcase-region'), which convert everything between
  709. point and mark to the specified case.  Point and mark do not move.
  710.    The region case conversion commands `upcase-region' and
  711. `downcase-region' are normally disabled.  This means that they ask for
  712. confirmation if you try to use them.  When you confirm, you may enable
  713. the command, which means it will not ask for confirmation again.  *Note
  714. Disabling::.
  715. File: emacs,  Node: Text Mode,  Next: Outline Mode,  Prev: Case,  Up: Text
  716. Text Mode
  717. =========
  718.    When you edit files of text in a human language, it's more convenient
  719. to use Text mode rather than Fundamental mode.  Invoke `M-x text-mode'
  720. to enter Text mode.  In Text mode, TAB runs the function
  721. `tab-to-tab-stop', which allows you to use arbitrary tab stops set with
  722. `M-x edit-tab-stops' (*note Tab Stops::.).  Features concerned with
  723. comments in programs are turned off except when explicitly invoked.
  724. The syntax table is changed so that periods are not considered part of
  725. a word, while apostrophes, backspaces and underlines are.
  726.    A similar variant mode is Indented Text mode, intended for editing
  727. text in which most lines are indented.  This mode defines TAB to run
  728. `indent-relative' (*note Indentation::.), and makes Auto Fill indent
  729. the lines it creates.  The result is that normally a line made by Auto
  730. Filling, or by LFD, is indented just like the previous line.  Use `M-x
  731. indented-text-mode' to select this mode.
  732.    Entering Text mode or Indented Text mode runs the hook
  733. `text-mode-hook'.  Other major modes related to Text mode also run this
  734. hook, followed by hooks of their own; this includes Nroff mode, TeX
  735. mode, Outline mode and Mail mode.  Hook functions on `text-mode-hook'
  736. can look at the value of `major-mode' to see which of these modes is
  737. actually being entered.  *Note Hooks::.
  738. * Menu:
  739.   Two modes similar to Text mode are of use for editing text that is to
  740. be passed through a text formatter before achieving the form in which
  741. humans are to read it.
  742. * Nroff Mode::  The major mode for editing input to the formatter nroff.
  743. * TeX Mode::    The major modes for editing input to the formatter TeX.
  744.   Another similar mode is used for editing outlines.  It allows you
  745. to view the text at various levels of detail.  You can view either
  746. the outline headings alone or both headings and text; you can also
  747. hide some of the headings at lower levels from view to make the high
  748. level structure more visible.
  749. * Outline Mode::The major mode for editing outlines.
  750. File: emacs,  Node: Outline Mode,  Next: TeX Mode,  Prev: Text Mode,  Up: Text
  751. Outline Mode
  752. ============
  753.    Outline mode is a major mode much like Text mode but intended for
  754. editing outlines.  It allows you to make parts of the text temporarily
  755. invisible so that you can see just the overall structure of the
  756. outline.  Type `M-x outline-mode' to switch to Outline mode as the
  757. major mode of the current buffer.  Type `M-x outline-minor-mode' to
  758. enable Outline mode as a minor mode in the current buffer.  When
  759. Outline minor mode is enabled, the `C-c' commands of Outline mode
  760. replace those of the major mode.
  761.    When a line is invisible in outline mode, it does not appear on the
  762. screen.  The screen appears exactly as if the invisible line were
  763. deleted, except that an ellipsis (three periods in a row) appears at
  764. the end of the previous visible line (only one ellipsis no matter how
  765. many invisible lines follow).
  766.    All editing commands treat the text of the invisible line as part of
  767. the previous visible line.  For example, `C-n' moves onto the next
  768. visible line.  Killing an entire visible line, including its
  769. terminating newline, really kills all the following invisible lines
  770. along with it; yanking it all back yanks the invisible lines and they
  771. remain invisible.
  772.    Entering Outline mode runs the hook `text-mode-hook' followed by the
  773. hook `outline-mode-hook' (*note Hooks::.).
  774. * Menu:
  775. * Format: Outline Format.       What the text of an outline looks like.
  776. * Motion: Outline Motion.       Special commands for moving through
  777.                                      outlines.
  778. * Visibility: Outline Visibility.  Commands to control what is visible.
  779. File: emacs,  Node: Outline Format,  Next: Outline Motion,  Up: Outline Mode
  780. Format of Outlines
  781. ------------------
  782.    Outline mode assumes that the lines in the buffer are of two types:
  783. "heading lines" and "body lines".  A heading line represents a topic in
  784. the outline.  Heading lines start with one or more stars; the number of
  785. stars determines the depth of the heading in the outline structure.
  786. Thus, a heading line with one star is a major topic; all the heading
  787. lines with two stars between it and the next one-star heading are its
  788. subtopics; and so on.  Any line that is not a heading line is a body
  789. line.  Body lines belong with the preceding heading line.  Here is an
  790. example:
  791.      * Food
  792.      
  793.      This is the body,
  794.      which says something about the topic of food.
  795.      
  796.      ** Delicious Food
  797.      
  798.      This is the body of the second-level header.
  799.      
  800.      ** Distasteful Food
  801.      
  802.      This could have
  803.      a body too, with
  804.      several lines.
  805.      
  806.      *** Dormitory Food
  807.      
  808.      * Shelter
  809.      
  810.      A second first-level topic with its header line.
  811.    A heading line together with all following body lines is called
  812. collectively an "entry".  A heading line together with all following
  813. deeper heading lines and their body lines is called a "subtree".
  814.    You can customize the criterion for distinguishing heading lines by
  815. setting the variable `outline-regexp'.  Any line whose beginning has a
  816. match for this regexp is considered a heading line.  Matches that start
  817. within a line (not at the beginning) do not count.  The length of the
  818. matching text determines the level of the heading; longer matches make
  819. a more deeply nested level.  Thus, for example, if a text formatter has
  820. commands `@chapter', `@section' and `@subsection' to divide the
  821. document into chapters and sections, you could make those lines count
  822. as heading lines by setting `outline-regexp' to
  823. `"@chap\\|@\\(sub\\)*section"'.  Note the trick: the two words
  824. `chapter' and `section' are equally long, but by defining the regexp to
  825. match only `chap' we ensure that the length of the text matched on a
  826. chapter heading is shorter, so that Outline mode will know that
  827. sections are contained in chapters.  This works as long as no other
  828. command starts with `@chap'.
  829.    Outline mode makes a line invisible by changing the newline before it
  830. into an ASCII control-M (code 015).  Most editing commands that work on
  831. lines treat an invisible line as part of the previous line because,
  832. strictly speaking, it *is* part of that line, since there is no longer a
  833. newline in between.  When you save the file in Outline mode, control-M
  834. characters are saved as newlines, so the invisible lines become ordinary
  835. lines in the file.  But saving does not change the visibility status of
  836. a line inside Emacs.
  837. File: emacs,  Node: Outline Motion,  Next: Outline Visibility,  Prev: Outline Format,  Up: Outline Mode
  838. Outline Motion Commands
  839. -----------------------
  840.    There are some special motion commands in Outline mode that move
  841. backward and forward to heading lines.
  842. `C-c C-n'
  843.      Move point to the next visible heading line
  844.      (`outline-next-visible-heading').
  845. `C-c C-p'
  846.      Move point to the previous visible heading line
  847.      (`outline-previous-visible-heading').
  848. `C-c C-f'
  849.      Move point to the next visible heading line at the same level as
  850.      the one point is on (`outline-forward-same-level').
  851. `C-c C-b'
  852.      Move point to the previous visible heading line at the same level
  853.      (`outline-backward-same-level').
  854. `C-c C-u'
  855.      Move point up to a lower-level (more inclusive) visible heading
  856.      line (`outline-up-heading').
  857.    `C-c C-n' (`next-visible-heading') moves down to the next heading
  858. line.  `C-c C-p' (`previous-visible-heading') moves similarly backward.
  859. Both accept numeric arguments as repeat counts.  The names emphasize
  860. that invisible headings are skipped, but this is not really a special
  861. feature.  All editing commands that look for lines ignore the invisible
  862. lines automatically.
  863.    More powerful motion commands understand the level structure of
  864. headings.  `C-c C-f' (`outline-forward-same-level') and `C-c C-b'
  865. (`outline-backward-same-level') move from one heading line to another
  866. visible heading at the same depth in the outline.  `C-c C-u'
  867. (`outline-up-heading') moves backward to another heading that is less
  868. deeply nested.
  869.